import { CurrUser, UserDispatchContext } from "@/providers/UserContextProvider"
import { Card } from "antd"
import { useContext } from "react"

function Welcome() {
    const dispatch = useContext(UserDispatchContext)
    const handleUserAction = () => {
        const newUser: CurrUser = {
            username: "newUsername",
            token: "newToken",
        }
        dispatch({ type: "updateUser", payload: newUser })
    }

    return (
        <Card className={"h-full"} title={"Welcome"} bordered={false}>
            <button
                onClick={() => {
                    console.log("set user name")
                    handleUserAction()
                }}
            >修改用户名</button>
            <div className={"h-full min-h-[500px] flex-col flex items-center justify-center"}>
                <h1 className={"text-2xl text-blue-700 text-center"}>欢迎页</h1>
                <p className={"text-center text-blue-700"}>welcome to use super-antd-admin</p>
            </div>
        </Card>
    )
}

export default Welcome
